package com.gimi.cloud.bbp.manage.consumer.service.mall.impl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.mall.MallAppRecommentGroupDTO;
import com.gimi.cloud.bbp.manage.consumer.feign.MallFeignService;
import com.gimi.cloud.bbp.manage.consumer.service.mall.MallRecommentGroupService;

/**
 * 推送组管理
 * @author chendi
 * @date 2018年2月1日
 */
@Service
public class MallRecommentGroupServiceImpl implements MallRecommentGroupService{
    private static final Logger logger = LoggerFactory.getLogger(MallRecommentGroupServiceImpl.class);

    private MallFeignService mallFeignService;

    @Autowired
    public MallRecommentGroupServiceImpl(MallFeignService mallFeignService) {
        this.mallFeignService = mallFeignService;
    }

    @Override
    public Response getRecommentGroupList(HttpServletRequest request, HttpServletResponse response, MallAppRecommentGroupDTO dto) throws Exception {
    	return mallFeignService.getAppRecommentGroupList(dto);
    }

    @Override
    public Response getRecommentGroupInfo(HttpServletRequest request, HttpServletResponse response, MallAppRecommentGroupDTO dto) throws Exception {
        if(null == dto.getArgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"推送组id为空，获取推送组列表失败");
            return resp;
        }
        return mallFeignService.getAppRecommentGroupInfo(dto);
    }

    @Override
    public Response addRecommentGroup(HttpServletRequest request, HttpServletResponse response, MallAppRecommentGroupDTO dto) throws Exception {
        if(null != dto.getArgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"Recomment组Id不为空，添加推送组信息失败");
            return resp;
        }
        return mallFeignService.saveOrUpdateRecommentGroup(dto);
    }

    @Override
    public Response editRecommentGroup(HttpServletRequest request, HttpServletResponse response, MallAppRecommentGroupDTO dto) throws Exception {
        if(null == dto.getArgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"推送组Id为空，修改推送组信息失败");
            return resp;
        }
        return mallFeignService.saveOrUpdateRecommentGroup(dto);
    }

    @Override
    public Response deleteRecommentGroup(HttpServletRequest request, HttpServletResponse response, MallAppRecommentGroupDTO dto) throws Exception {
        if(null == dto.getArgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"推送组Id为空，删除推送组信息失败");
            return resp;
        }
        return mallFeignService.deleteRecommentGroup(dto);
    }
}
